import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:thinking/entity/_.dart';
import 'package:thinking/utils/_.dart';
import 'package:thinking/widget/_.dart';

class UserItemWidget extends StatelessWidget {
  final UserData userData;
  final bool showButton;
  final bool showDivider;
  final Color titleColor;
  final double panelLeft;
  final String subtitle;
  UserItemWidget(
      {required this.userData,
      this.showButton: true,
      this.showDivider: true,
      this.titleColor: Colors.black,
      this.panelLeft: 10,
      this.subtitle: ''});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: Screen.width(context),
      child: Panel(
        top: 10,
        bottom: 10,
        left: panelLeft,
        child: Column(
          children: [
            Row(
              children: [
                Expanded(
                  child: ListTile(
                      leading: ClipRRect(
                        borderRadius: BorderRadius.circular(30),
                        child: ClipOval(
                          child: Image.network(
                            userData.userHeadImg!,
                            height: Screen.setWidth(48),
                            width: Screen.setWidth(48),
                            fit: BoxFit.cover,
                          ),
                        ),
                      ),
                      title: Text(
                        userData.userNickName != '暂无'
                            ? userData.userNickName.toString()
                            : userData.userPhone.toString(),
                        style: TextStyle(
                            color: titleColor, fontWeight: FontWeight.bold),
                      ),
                      subtitle: subtitle == ''
                          ? Text(
                              userData.userUserInfo!.userAutograph != null
                                  ? userData.userUserInfo!.userAutograph!
                                  : '这个人很懒，还没写签名~',
                              softWrap: false,
                              overflow: TextOverflow.ellipsis,
                            )
                          : Text(subtitle,
                        softWrap: false,
                        overflow: TextOverflow.ellipsis,)),
                ),
                Visibility(
                  child: FollowButton(userData: userData),
                  visible: showButton,
                ),
              ],
            ),
            Visibility(
              child: Divider(),
              visible: showDivider,
            )
          ],
        ),
      ),
    );
  }
}
